import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
  RouteRecordRaw,
} from "vue-router";
import { TrendCharts, Menu, List } from "@element-plus/icons-vue";
const routes: Array<RouteRecordRaw> = [
  // 默认跳转的页面
  {
    path: "/",
    redirect: "login", // 重定向
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("../views/login/index.vue"),
  },
  {
    path: "/home",
    name: "Home",
    component: () => import("../views/home/index.vue"),
    children: [
      {
        path: "/echarts",
        name: "Echarts",
        component: () => import("../views/home/children/EchartsView.vue"),
        meta: {
          title: "数据展示",
          icon: TrendCharts,
        },
      },
      {
        path: "/pay",
        name: "Pay",
        component: () => import("../views/home/children/PayList.vue"),
        meta: {
          title: "缴费管理",
          icon: Menu,
        },
      },
      {
        path: "/user",
        name: "User",
        component: () => import("../views/home/children/UserOne.vue"),
        meta: {
          title: "住户信息",
          icon: List,
        },
        children: [
          {
            path: "/userlist",
            name: "Userlist",
            component: () => import("../views/home/children/UserList.vue"),
            meta: {
              classifyTitle: "住户信息",
              title: "住户信息列表",
            },
          },
          {
            path: "/userupdate",
            name: "Userupdate",
            component: () => import("../views/home/children/UserUpdate.vue"),
            meta: {
              classifyTitle: "住户信息",
              title: "住户信息更新",
            },
          },
        ],
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL), // hash 模式
  routes,
});

export default router;
